#include <stdio.h>
#include <unistd.h>
#include <string.h>
#include <sys/shm.h>

#define IPC_KEY 0X12345678
#define PROJ_ID 0x123456 
int main()
{
   
  key_t key=ftok("./",PROJ_ID);
  int shmid=shmget(key,4096,IPC_CREAT | 0664);
  //int shmid=shmget(IPC_KEY,4096,IPC_CREAT | 0664);
 if(shmid<0)
 {
   perror("shmget error");
   return -1;
 }

 void *shm_start=shmat(shmid,NULL,0);
 if(shm_start ==(void*)-1)
 {
   perror("shmat error");
   return -1;
 }

 while(1)
 {
   printf("%s\n",shm_start );
   sleep(1);
 }

 shmdt(shm_start);
 shmctl(shmid,IPC_RMID,NULL);
  return 0;
}
